package com.newsystem.MyUtils;

import org.springframework.web.multipart.MultipartFile;

import java.util.UUID;

public class MyUUIDUtils {
    public static String getUUID(){
        return UUID.randomUUID().toString();
    }
    public static String getUUIDFileName(String fileName){
        System.out.println(fileName);
        int idx = fileName.lastIndexOf('.');
        System.out.println(idx);
        String tail = fileName.substring(idx);
        String UUIDFileName = getUUID().replace("-","")+tail;
        return UUIDFileName;
    }
    public static String getUUIDFileName(MultipartFile file){
        String fileName = file.getOriginalFilename();
        int idx = fileName.lastIndexOf(".");
        String tail = fileName.substring(idx);
        String UUIDFileName = getUUID().replace("-","")+tail;
        return UUIDFileName;
    }
}
